Reject Pipfile entries with unrecognized keys#6611
Draft
Conversation
Fixes #5642 Previously, pipenv silently ignored unrecognized keys in Pipfile package entries. For example, writing `commit = "hash"` instead of `ref = "hash"` for a VCS dependency would be silently ignored, causing the dependency to point at HEAD instead of the intended commit. This adds validation at two levels: 1. plette layer (PackageSpecfiers.validate): Checks for unknown keys when the Pipfile is loaded/validated via plette.Pipfile.load(). 2. dependencies layer (_validate_pipfile_entry): Checks for unknown keys when install_req_from_pipfile() processes individual package entries during install/lock operations. Both raise clear error messages listing the unrecognized key(s) and the valid options available.
Contributor
|
I think this fix be implemented in plette directly? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5642
Previously, pipenv silently ignored unrecognized keys in Pipfile package entries. For example, writing
commit = "hash"instead ofref = "hash"for a VCS dependency would be silently ignored, causing the dependency to point at HEAD instead of the intended commit.Changes
This adds validation at two levels:
plette layer (
PackageSpecfiers.validateinpipenv/vendor/plette/models/packages.py): DefinesKNOWN_PACKAGE_KEYS— a frozenset of all recognized keys for a Pipfile package entry — and validates against it when the Pipfile is loaded viaplette.Pipfile.load().dependencies layer (
_validate_pipfile_entryinpipenv/utils/dependencies.py): Validates package entries wheninstall_req_from_pipfile()processes them during install/lock operations, raisingPipenvUsageErrorwith a clear message.Example
Given this Pipfile:
Pipenv will now produce:
Testing
All 375 existing unit tests continue to pass.
Pull Request opened by Augment Code with guidance from the PR author